package com.lld.im.common.model;

import lombok.Data;

import java.util.Objects;


@Data
public class UserSession {
    private String userId;

    /**
     * 应用ID
     */
    private String appId;

    /**
     * 端的标识
     */
    private Integer clientType;

    //sdk 版本号
    private Integer version;

    //连接状态 1=在线 2=离线
    private Integer connectState;

    /**
     * 服务器id
     */
    private String brokerId;

    /**
     * 服务器ip地址
     */
    private String brokerHost;

    private String imei;


    public UserSession(String userId, String appId, Integer clientType, String imei) {
        this.userId = userId;
        this.appId = appId;
        this.clientType = clientType;
        this.imei = imei;
    }

    public UserSession() {
    }

    public UserSession(String appId, String userId, int clientType) {
        this.appId = appId;
        this.userId = userId;
        this.clientType = clientType;
    }

    @Override
    public int hashCode() {
        return 0;
    }

    /**
     * 基于业务要求 需要重写equals 保证在map取值时使用
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserSession userKey = (UserSession) o;
        return Objects.equals(appId, userKey.appId) &&
                Objects.equals(userId, userKey.userId) &&
                Objects.equals(clientType, userKey.clientType);
    }
}
